{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "37a40b9b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入支付宝余额：6\n",
      "['吧唧', 3]\n",
      "['立牌', 4]\n",
      "['钥匙扣', 5]\n",
      "['色纸', 9]\n",
      "['收藏卡', 2]\n",
      "你需要什么商品：吧唧\n",
      "吧唧价格为3\n",
      "已经为你加入购物车\n",
      "购物车内： ['吧唧']\n",
      "['吧唧', 3]\n",
      "['立牌', 4]\n",
      "['钥匙扣', 5]\n",
      "['色纸', 9]\n",
      "['收藏卡', 2]\n"
     ]
    }
   ],
   "source": [
    "alipay = int(input(\"请输入支付宝余额：\"))\n",
    "商品列表 = [[\"吧唧\",3],[\"立牌\",4],[\"钥匙扣\",5],[\"色纸\",9],[\"收藏卡\",2]]\n",
    "商品列表号码 = [\"1\",\"2\",\"3\",\"4\",\"5\"]\n",
    "商品列表号码 = 商品列表\n",
    "可买商品 = ()\n",
    "购物车 = []\n",
    "while True:\n",
    "    for i in 商品列表:\n",
    "        print(i)\n",
    "    user_choose = input(\"你需要什么商品：\")   \n",
    "    if user_choose == \"吧唧\":\n",
    "        print(\"吧唧价格为3\")\n",
    "        if alipay >= 3:\n",
    "            可买商品 = \"吧唧\"\n",
    "            print(\"已经为你加入购物车\")\n",
    "        else:\n",
    "            print(\"您的余额不足，请努力赚钱吧\")\n",
    "    elif user_choose == \"立牌\":\n",
    "        print(\"立牌价格为4\")\n",
    "        if alipay >= 4:\n",
    "            可买商品 = \"立牌\"\n",
    "            print(\"已经为你加入购物车\")\n",
    "        else:\n",
    "            print(\"您的余额不足，请努力赚钱吧\")\n",
    "    elif user_choose == \"钥匙扣\":\n",
    "        print(\"钥匙扣价格为5\")\n",
    "        if alipay >= 5:\n",
    "            可买商品 = \"钥匙扣\"\n",
    "            print(\"已经为你加入购物车\")\n",
    "        else:\n",
    "            print(\"您的余额不足，请努力赚钱吧\")\n",
    "    elif user_choose == \"色纸\":\n",
    "        print(\"色纸价格为9\")\n",
    "        if alipay >= 9:\n",
    "            可买商品 = \"色纸\"\n",
    "            print(\"已经为你加入购物车\")\n",
    "        else:\n",
    "            print(\"您的余额不足，请努力赚钱吧\")\n",
    "    elif user_choose == \"收藏卡\":\n",
    "        print(\"收藏卡价格为2\")\n",
    "        if alipay >= 2:\n",
    "            可买商品 = \"收藏卡\"\n",
    "            print(\"已经为你加入购物车\")\n",
    "        else:\n",
    "            print(\"您的余额不足，请努力赚钱吧\")\n",
    "    else:\n",
    "         print(\"无此商品\")\n",
    "    购物车.append(可买商品)\n",
    "    print(\"购物车内：\" ,购物车)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c0052c11",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9b818fb4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
